package com.test.ioc.controller;

import com.test.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class HelloController {
//    @Autowired
    private UserService userService;
    public HelloController(){

    }
    //构造方法注入
//    @Autowired
//    public HelloController(UserService userService){
//        this.userService=userService;
//    }
    //Setter方法注入
    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void sayHello(){
        userService.doService();
        System.out.println("hello ,useController...");
    }
}
